<template>
    <div>
        <div class="goods">
            <div class="menu-wrapper" ref="menuWrapper">
                <ul>
                    <li class="menu-item current" v-for="(Category,index) of ProductCategory" :key="index">
                        <span class="text">
                            <img :src="`./imgs/categoryName${Category.scId}.svg`">
                            {{Category.categoryName}}
                        </span>
                    </li>
                </ul>
            </div>

            <div class="foods-wrapper" ref="foodsWrapper">
                <ul>
                    <li class="food_list" v-for="(Category,index) of ProductData" :key="index">
                        <h1 class="category">{{Category.categoryName}}</h1>
                        <ul>
                            <li class="food_item" v-for="(food,index) of Category.shops" :key="index">
                                <div class="icon">
                                    <img :src="food.coverImg" width="80" height="80" alt="">
                                </div>
                                <div class="content">
                                    <h2 class="name">{{food.shopName}}</h2>
                                    <h5 class="desc" v-if="food.shopIntroduction!=''">{{food.shopIntroduction}}</h5>
                                    <h5 class="desc" v-if="food.shopIntroduction==''">假装这是一条描述...</h5>
                                    <!-- <div class="extra"> -->
                                        <!-- <span class="count">月售{{food.sellCount}}份</span> -->
                                        <!-- <span>好评率{{food.rating}}%</span> -->
                                    <!-- </div> -->
                                    <div class="price">
                                        <span class="now">￥{{food.originalPrice}}</span>
                                        <span class="old" v-if="food.oldPrice">￥{{food.oldPrice}}</span>
                                    </div>
                                    <div class="cartcontrol_wrapper">CartControl</div>
                                </div>
                            </li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</template>

<script>
import BScroll from "better-scroll";
import { mapState } from "vuex";

export default {
  name: "GoodsList",
  data() {
    return {
      scrollY: 0,
      tops: []
    };
  },
  computed: {
    ...mapState(["ProductCategory", "ProductData"])
  },
  mounted() {
    this.$store.dispatch("getProductCategory");
    // , () => {
    //   this.$nextTick(() => {
    //     new BScroll(".menu-wrapper");
    //   });
    // });
    this.$store.dispatch("getProductData");
    // , () => {
    //   this.$nextTick(() => {
    //     new BScroll(".foods-wrapper");
    //   });
    // });
  }
};
</script>

<style lang="scss" scoped>
ul {
  margin: 0;
  padding: 0;
}
.goods {
  display: flex;
  position: absolute;
  //   background-color: green;
  bottom: 55px;
  top: 80px;
  width: 100%;
  overflow: hidden;
  .menu-wrapper {
    width: 25%;
    // background-color: blue;
    .menu-item {
      display: table;
      height: 50px;
      width: 100%;
      line-height: 14px;
      .text {
        display: table-cell;
        width: 56px;
        font-size: 14px;
        font-weight: 400;
        vertical-align: middle;
        border-bottom: 1px solid (rgba(7, 17, 27, 0.1));
        text-align: center;
        img {
          width: 14px;
          height: 14px;
          margin-right: 2px;
          vertical-align: center;
        }
      }
    }
  }
}

.foods-wrapper {
  width: 75%;
  //   background-color: yellow;
  //   padding: 0 10px;
  .food_list {
    margin-top: 10px;
    .category {
      height: 20px;
      line-height: 20px;
      border-left: 2px solid #d9dde1;
      font-size: 14px;
      color: rgb(147, 153, 159);
      background: #f3f5f7;
      padding-left: 3px;
    }
    .food_item {
      height: 100px;
      width: 100%;
      // background-color: pink;
      display: flex;
      padding: 6px;
      margin-top: 10px;
      border-bottom: 1px solid (rgba(7, 17, 27, 0.1));
      .icon {
        margin-right: 10px;
      }
      .content {
        position: relative;
        width: 100%;
        .name {
          font-size: 16px;
          line-height: 16px;
          font-weight: 700;
          color: rgb(7, 17, 27);
        }
        .desc,
        .extra {
          font-size: 10px;
          line-height: 12px;
          color: rgb(147, 153, 159);
        }
        .desc {
          height: 22px;
        }
        .extra {
          line-height: 12px;
          .count {
            margin-right: 12px;
          }
        }
        .price {
          font-weight: 700;
          line-height: 24px;
          .now {
            color: rgb(240, 20, 20);
            font-size: 14px;
            margin-right: 8px;
          }
          .old {
            text-decoration: line-through;
            font-size: 10px;
            color: rgb(147, 153, 159);
          }
        }
        .cartcontrol_wrapper {
          position: absolute;
          right: 0;
          bottom: -5px;
        }
      }
    }
  }
}
</style>
